package com.xuanwu.ai.flow.controller;

import com.github.pagehelper.PageInfo;
import com.xuanwu.ai.flow.dto.FlowDataReqDTO;
import com.xuanwu.ai.flow.dto.FlowDataResDTO;
import com.xuanwu.ai.flow.service.FlowDataServiceImpl;
import com.xuanwu.ai.jdbc.page.Pagination;
import com.xuanwu.ai.web.views.ResponseVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value = "流程数据相关接口", produces = "application/json")
@RestController
@RequestMapping("/flowData")
@Slf4j
public class FlowDataController {
    @Autowired
    private FlowDataServiceImpl flowDataService;

    @PostMapping("/getList")
    @ApiOperation(value = "获取流程数据列表", notes = "获取流程数据列表")
    public ResponseVo<PageInfo<FlowDataResDTO>> getList(@RequestBody FlowDataReqDTO flowDataReqDTO,
                                                        @RequestParam("pageNum") Integer pageNum,
                                                        @RequestParam("pageSize") Integer pageSize){
        Pagination pagination = new Pagination(pageNum, pageSize);
        return ResponseVo.success(flowDataService.getFlowDataList(flowDataReqDTO, pagination));

    }

    @GetMapping("/getDetail")
    @ApiOperation(value = "获取流程数据", notes = "获取流程数据")
    public ResponseVo<FlowDataResDTO> getDetail(@RequestParam("requestId") String requestId){
        return ResponseVo.success(flowDataService.getFlowDataByRequestId(requestId));

    }

}
